<template>
	<view class="NewsItem">
		<view class="pic">
			<image :src="item.picurl" mode="aspectFill"></image>
		</view>
		<view class="text">
			<view class="title">{{item.title}}</view>
			<view class="info" v-if="!item.lookTime">
				<text>{{item.author}}</text>
				<text>{{item.hits}}浏览</text>
			</view>
			<view class="info" v-else>
				<text v-if="item.author">{{item.author}}</text>
				<text>浏览时间:{{item.lookTime}}</text>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		name:"NewsItem",
		props:{
			item:{
				type:Object,
				default(){
					return {
						title:"组件内默认标题",
						author:"里大帅",
						hits:668,
						picurl:"../../static/images/nopic.jpg",
						lookTime:"2023-2-28 21:30:30",
					}
				}
			}
		},
		data() {
			return {
			};
		},
	}
</script>

<style lang="scss">
.NewsItem{
	padding:30rpx ;
	border-bottom: 1px dashed #efefef;
	display: flex;
	
	.pic{
		width: 230rpx;
		height:160rpx;
		image{
			width: 100%;
			height: 100%;
		}
	}
	.text{
		flex: 1;
		padding-left:20rpx;
		display: flex;
		flex-direction: column;
		justify-content: space-between;
		// 最多显示两行，其余省略号表示
		.title{
			font-size: 36rpx;
			width: 400rpx;
			text-overflow: -o-ellipsis-lastline;
			overflow: hidden;
			text-overflow: ellipsis;
			display: -webkit-box;
			-webkit-line-clamp: 2;
			line-clamp: 2;
			-webkit-box-orient:vertical;
			color: #333;
		}
		.info{
			font-size: 26rpx;
			color: #999;
			text{
				padding-right: 30rpx
			};
		}
	}
}
</style>